package top.yonyong.mock.service;

import org.junit.Assert;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.powermock.api.mockito.PowerMockito;
import top.yonyong.mock.BaseMock;
import top.yonyong.mock.entity.Student;
import top.yonyong.mock.mapper.StudentMapper;
import top.yonyong.mock.service.impl.UserServiceImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yonyong
 **/
public class MockUserviceImpl extends BaseMock{

    @InjectMocks
    private UserServiceImpl userService;

    @Mock
    private StudentMapper studentMapper;

//    @Before
//    public void initMocks(){
//        MockitoAnnotations.initMocks(this);
//    }

    @Test
    public void test(){
        List<Student> list = new ArrayList<>();
        final Student student = new Student();
        student.setId(1001);
        student.setAge(18);
        student.setName("yonyong");
        student.setSex('男');
        student.setScore(100.0);
        list.add(student);
        PowerMockito.when(studentMapper.selectAll()).thenReturn(list);
        Assert.assertEquals(null,userService.getAll());
    }
}
